package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.utils.RedisCache;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("adminShopController") //adminShopController 防止两个同名的ShopController发生冲突
@RequestMapping("/admin/shop")
@Api(tags = "店铺操作相关接口")
public class ShopController {

    @Autowired
    private RedisCache redisCache;

    @PutMapping("/{status}")
    @ApiOperation("设置营业状态")
    public Result updateShopStatus(@PathVariable String status){
        redisCache.setCacheObject("SHOP_STATUS",status);
        return Result.success();
    }

    @GetMapping("/status")
    @ApiOperation("获取营业状态")
    public Result getShopStatus(){
        String shopStatus = redisCache.getCacheObject("SHOP_STATUS");
        return Result.success(Integer.valueOf(shopStatus));
    }

}
